package com.gitee.ed.example.caffeine;

import com.github.benmanes.caffeine.cache.RemovalCause;
import com.github.benmanes.caffeine.cache.RemovalListener;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author hongda.li
 */
public class LoggerListener<V> implements RemovalListener<String, V> {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public void onRemoval(@Nullable String key, @Nullable V value, RemovalCause cause) {
        logger.debug("Remove cache cause of [{}]", cause.name());
        logger.debug("Remove cache key and value [{} - {}]", key, value);
    }
}
